window.onload=function(){
    
    let bun=document.querySelector("button")
    let bun_post=document.querySelector("#bun_post")
    bun.addEventListener("click",()=>{
        let username = document.getElementById("username").value
        let password = document.getElementById("password").value
        fetch("http://172.19.1.251:8080/login",{
           method:"GET",
           headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        }
        }).then((res)=>{
            console.log("success")
            return res.text()
        }).then((res)=>{
            console.log(res)
        }).catch(()=>{
            console.log("fail")
        })
    })

    bun_post.addEventListener("click",()=>{
        let username = document.getElementById("username").value
        let password = document.getElementById("password").value
        data={
            username:"username",
            password:"password"
        }
        fetch("http://172.19.1.251:8080/login",{
            method:"POST",
            headers:{
                "Content-Type":"application/json"
            },
            body:JSON.stringify(data)
        }).then((res)=>{
            console.log("success")
            return res.text()
        }).then((res)=>{
            console.log(res)
        }).catch(()=>{
            console.log("fail")
        })
    })
}